package edu.yourl.presenter;

import edu.yourl.domain.User;
import edu.yourl.web.IProfilePage;
import edu.yourl.web.ProfilePage;

public class ProfilePagePresenter extends BasePagePresenter implements
		IProfilePagePresenter {

	@Override
	public void init(IProfilePage profilePage) {
		User user = this.getCurrentUser(profilePage);
		profilePage.setEmail(user.getMail());
		profilePage.setName(user.getName());
		profilePage.setPassword(user.getPassword());
		profilePage.setNickName(user.getFavoritableName());
	}
	
	@Override
	public void changeUserData(ProfilePage profilePage) {
		User user = this.getCurrentUser(profilePage);
		user.modify(profilePage.getEmail(),profilePage.getName(),profilePage.getPassword());
		this.userRepository.add(user);
	}

}
